package 运输配货系统;

import java.util.Scanner;

public class UserList {
	User []userList;
	public UserList(int n) {

		
		userList=new User[n];
		
		for(int i=0;i<userList.length;i++) {
			userList[i]=new User();
		}
		
	}
	
	public  void AddUser() {                             //增
		
		User [] userList1=new User[userList.length+1];
		for(int i=0;i<userList.length;i++) {
			userList1[i]=userList[i];
			
		}
		userList1[userList1.length-1]=new User();
		userList=userList1;
		
	}
	public static void  removeUser(UserList a,User b) {    //删
		int i;
	for( i=0;i<a.userList.length;i++)
	{
		    if(b==a.userList[i]) {
		    	break;
		    } 
	}
	
	for(i=i+1;i<a.userList.length;i++)
	{
		a.userList[i-1]=a.userList[i];
		
	}     
	             
	
	User [] userList1=new User[a.userList.length-1];
	for(int j=0;j<userList1.length;j++) {
		userList1[j]=a.userList[j];
		
	}
	
	a.userList=userList1;
	
	                                                 }        
	
	public static void upDate(User b)           {             //改
		
		
		System.out.println("请输入新的姓名 电话 id 地址");
		Scanner scanner=new Scanner(System.in);
		b.name=scanner.next();
	
			String number1=scanner.next();
	if(number1.length()==11)
	{
		for(int ii=0;ii<number1.length();ii++) {
			int j=number1.charAt(ii)-48;
			if(j>=0&&j<10) {
				b.number[ii]=j;
			}
			else {
				System.out.println("手机号输入格式错误（非数字）");
				
			     }
				
			
		}
	}
	else {
		System.out.println("手机号输入格式错误(长度)");
	     }
		
			String id1=scanner.next();
			
			if(id1.length()==7)
			{
				
				for(int ii=0;ii<id1.length();ii++) {
					int j=id1.charAt(ii)-48;
					if(j>=0&&j<10) {
						b.id[ii]=j;
					}
					else {
						System.out.println("id号输入格式错误（非数字）");
						
					     }
						
					
				}
			}
			else {
				System.out.println("id号输入格式错误(长度)");
			}
			
		b.address=new Address();
	
		
	                                                       }
	
	
	public static void search(User b) {                //查
		
	
	
		
		System.out.println(" 用户名"+b.getName()+" 用户id: "+b.getId()+" 用户号码 "+b.getNumber()+" 用户地址"+b.getAddress()+" 用户订单数量："+b.orderNumber+ "订单号为："+ b.getOrderID());
		
		
		
	                                               }
	

}
